package seeders

import (
	"github.com/goravel/framework/facades"
	"goravel/app/models"
)

type DeviceSeeder struct {
}

// Signature The name and signature of the seeder.
func (s *DeviceSeeder) Signature() string {
	return "DeviceSeeder"
}

// Run executes the seeder logic.
func (s *DeviceSeeder) Run() error {
	devices := []models.Device{}
	if err := facades.Orm().Factory().Count(1).Create(&devices); err != nil {
		panic(err.Error())
	}
	//	获取第一个
	device := models.Device{}

	facades.Orm().Query().Model(&models.Device{}).First(&device)
	//860355079154511
	//更新SerialNumber
	device.Code = "860355079154511"
	facades.Orm().Query().Model(&models.Device{}).Where("id=?", device.ID).Update("code", device.Code)
	return nil
}
